module ActiveDirectory
  module Datatypes
    class Timestamp
      AD_DIVISOR = 10_000_000
      AD_OFFSET = 11_644_473_600

      def self.to_local(value)
        Time.at( (value.to_i / AD_DIVISOR) - AD_OFFSET)
      end

      def self.to_remote(value)
        (value.to_i + AD_OFFSET) * AD_DIVISOR
      end
    end
  end
end
